﻿' Copyright © Microsoft Corporation.  All Rights Reserved.
' This code released under the terms of the 
' Microsoft Public License (MS-PL, http://opensource.org/licenses/ms-pl.html.)
'
' Copyright (c) Microsoft Corporation. All rights reserved.
Public Class ImageViewer


    ' This method overloads the default Show method so that an argument
    ' can be passed for displaying the image based on a Stream returned
    ' by GetHttpStream() on frmMain.
    Public Overloads Sub Show(ByVal strImgSrc As String)
        Dim frmMain As New MainForm()

        With picImage
            Try
                ' Set the PictureBox Image property to the Image generated by
                ' the Http response stream.
                .Image = Image.FromStream(frmMain.GetHttpStream(strImgSrc))
            Catch exp As Exception
                MsgBox(exp.ToString, MsgBoxStyle.Critical, Me.Text)
            End Try

            .SizeMode = PictureBoxSizeMode.CenterImage
        End With

        lblImageFilename.Text = strImgSrc

        Me.Show()
        Application.DoEvents()
    End Sub

    ' Handles the "Close" button Click event. Hides the Form.
    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Hide()
    End Sub

End Class